$(document).ready(function () {
  let nav_lis = $('li', '.nav')
  console.log(nav_lis);
  $(nav_lis[0]).addClass('current')
  let current_href = window.location.href.split('/')[3]
  nav_lis.each(function (index, item) {
    let a_href = $('a', item).attr('href')
    if (a_href == current_href) {
      $(nav_lis[0]).removeClass('current')
      $(this).addClass('current')
    }
  })
})

window.onload = function () {
  var swiper = new Swiper('.swiper-container', {
    slidesPerView: 3,
    spaceBetween: 30,
    centeredSlides: true,
    loop: true,
  });
}
$(document).ready(function () {
  let do_lis = $('li', '.do_somethings')
  console.log(do_lis);

  do_lis.each(function (index,item) {
    $(item).hover(function () {
      $(this).addClass('do_current')
      $(this).siblings().removeClass('do_current')
    })
  })
})
$(document).ready(function () {
  let hot_bottom = $('.hot_bottom')
  let titles = ['司法公正', '检验检疫', '质量技术', '知识产权', '科技创新', '涉外服务', '海关口岸', '招标拍卖', '商务贸易', '抵押质押', '人力资源', '融资信贷']
  let icons = []
  for (let i = 1; i <= 12; i++) {
    let index = i
    if (i < 10) {
      index = '0' + i
    }
    let eachIcon = `public/images/open${index}.png`
    icons.push(eachIcon)
  }
  // console.log(icons);
  for (let j = 1; j <= 30; j++) {
    // console.log(j % 12);
    let now = j % 12
    // if (now == 0) {
    //   now = 12
    // }
    console.log(now);
    let each_insert_dom = `
    <li>
      <i>
        <img src=${icons[now]}>
      </i>
      <span>${titles[now]}</span>
    </li>
    `
    hot_bottom.append(each_insert_dom)
  }

  for (let j = 1; j <= 12; j++) {
    // console.log(j % 12);
    let now = j % 12
    // if (now == 0) {
    //   now = 12
    // }
    console.log(now);
    let each_insert_dom = `
    <li>
      <i>
        <img src=${icons[now]}>
      </i>
      <span>${titles[now]}</span>
    </li>
    `
    $('.news_bottom').append(each_insert_dom)
  }
})

$(document).ready(function () {
  // 插入含有图片容器的函数
  const inner_pic_container = function (dom, url, text) {
    let pic_container = $(dom)
    let pic_container_model =
      `
      <img src="${url}">
      <div class='box_shadow'>
        <span>${text}</span>
        <ul class='point'>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
        <ul>
      </div>
      `
    console.log(pic_container);
    console.log(pic_container_model);
    pic_container.append(pic_container_model)
  }
  // 插入列表容器函数
  const inner_list_container = function (dom, topArr, bottomLeftArr, bottomRightArr) {
    let list_container = $(dom)
    list_container.append($(`
    <div class= "list_top" >
      <ul class="top"></ul>
    </div>
    <div class= "list_bottom" >
      <ul class="bottom"></ul>
    </div>
    `))
    let topLi = ''
    for (let i = 0; i < topArr.length; i++) {
      topLi += `<li>${topArr[i]}</li>`
    }
    console.log(topLi);
    // let topLiModel = $('.list_top', dom).append($('ul.top')).append($(topLi))
    let bottomLi = ''
    for (let j = 0; j < bottomLeftArr.length; j++) {
      bottomLi +=
        `
      <li>
        <span class='title'>${bottomLeftArr[j]}</span>
        <span class='time'>${bottomRightArr[j]}</span>
      </li>
      `
    }
    $('ul.top',dom).append($(topLi))
    $('ul.bottom',dom).append($(bottomLi))
  }
  // 插入第一个含有图片的容器
  inner_pic_container('.pic_container1', 'public/images/publish_pic01.png', '回首峥嵘岁月、感受光辉历程')
  let list_container1_topArr = ['通知公告', '政务动态', '部门动态', '各区动态', '便民提醒']
  let list_container1_bottomLeftArr = ['关于印发自治区三级公立医院绩效考核工作实施方案的通知', '蔡奇到北京经济技术开发区调研时强调', '7月份25个街乡镇“接诉即办”考核并列第一', '全市各级人大代表将就修订生活垃圾管理条例赴基层征求意见', '关于印发自治区三级公立医院绩效考核工作实施方案的通知', '蔡奇到北京经济技术开发区调研时强调', '7月份25个街乡镇“接诉即办”考核并列第一', '全市各级人大代表将就修订生活垃圾管理条例赴基层征求意见']
  let list_container1_bottomRightArr = ['08-04','08-04','08-04','08-04','08-04','08-04','08-04','08-04']
  inner_list_container('.list_container1', list_container1_topArr, list_container1_bottomLeftArr, list_container1_bottomRightArr)
  
  inner_pic_container('.pic_container2', 'public/images/publish_pic02.png', '回首峥嵘岁月、感受光辉历程')
  inner_list_container('.list_container2', list_container1_topArr, list_container1_bottomLeftArr, list_container1_bottomRightArr)
  let list_container3_topArr = ['新闻发布','政策解读','市场监督','信息公开','数据发布']
  let list_container3_bottomLeftArr = ['关于印发自治区三级公立医院绩效考核工作实施方案的通知', '蔡奇到北京经济技术开发区调研时强调', '7月份25个街乡镇“接诉即办”考核并列第一', '全市各级人大代表将就修订生活垃圾管理条例赴基层征求意见', '关于印发自治区三级公立医院绩效考核工作实施方案的通知', '蔡奇到北京经济技术开发区调研时强调', '7月份25个街乡镇“接诉即办”考核并列第一', '全市各级人大代表将就修订生活垃圾管理条例赴基层征求意见','关于印发自治区三级公立医院绩效考核工作实施方案的通知']
  let list_container3_bottomRightArr = ['08-04','08-04','08-04','08-04','08-04','08-04','08-04','08-04','08-04']
  inner_list_container('.list_container3', list_container3_topArr, list_container3_bottomLeftArr, list_container3_bottomRightArr)
  inner_list_container('.list_container4', list_container3_topArr, list_container3_bottomLeftArr, list_container3_bottomRightArr)
})